import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// 线性布局 row Column

class LinearLayoutRoute extends StatefulWidget {
  @override
  _LinearLayoutRouteState createState() => _LinearLayoutRouteState();
}

class _LinearLayoutRouteState extends State<LinearLayoutRoute> {
  List<Widget> rowLs;
  List<Widget> columnLs;

  @override
  void initState() {
    super.initState();
    rowLs = [
      Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text("hello world"),
          Text("I am jack"),
        ],
      ),
      Row(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Text("hello world"),
          Text("I am jack"),
        ],
      ),
      Row(
        mainAxisAlignment: MainAxisAlignment.end,
        textDirection: TextDirection.rtl,
        children: <Widget>[
          Text("hello world"),
          Text("I am jack"),
        ],
      ),
      Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        verticalDirection: VerticalDirection.up,
        children: <Widget>[
          Text("hello world", style: TextStyle(fontSize: 30.0)),
          Text("I am jack"),
        ],
      ),
    ];

    columnLs = [
      Text("hi"),
      Text("world"),
    ];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("线性布局：row column"),
        ),
        body: Container(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Text("水平排列：row"),
              Column(children: rowLs),
              Text("垂直排列：column"),
              Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: columnLs,
              ),
              ConstrainedBox(
                constraints: BoxConstraints(minWidth: double.infinity),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: columnLs,
                ),
              ),
            ],
          ),
        ));
  }
}
